package com.chen.demoa;

import org.apache.commons.codec.digest.DigestUtils;
import org.springframework.web.servlet.HandlerInterceptor;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.logging.Filter;
import java.util.logging.LogRecord;

public class filter implements HandlerInterceptor {
    private String secret = "7yuijhyt45de2";
    @Override
    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {

        Long timestamp = Long.valueOf(request.getHeader("timestamp"));
        String token = request.getHeader("token");
        String sign = request.getHeader("sign");
        String localSign = DigestUtils.sha1Hex(token + timestamp + secret);
        System.out.println(localSign);
        return false;
    }
}
